package cn.kongwg.aopanno;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * @author kongwg
 * @create 2021-02-24 20:03
 */
@Component
@Aspect
@Order(3)
public class ProxyUser {

    @Pointcut("execution(* cn.kongwg.bean.User.add(..))")
    public void pointDemo(){

    }

    @Before("pointDemo()")
    public void before() {
        System.out.println("before......");
    }

    @After("execution(* cn.kongwg.bean.User.add(..))")
    public void after() {
        System.out.println("after......");
    }

    @AfterReturning("execution(* cn.kongwg.bean.User.add(..))")
    public void afterReturning() {
        System.out.println("afterReturning......");
    }

    @AfterThrowing("execution(* cn.kongwg.bean.User.add(..))")
    public void afterThrowing() {
        System.out.println("afterThrowing......");
    }

    @Around("execution(* cn.kongwg.bean.User.add(..))")
    public void around(ProceedingJoinPoint proceedingJoinPoint) throws Throwable{

        System.out.println("around钱......");

        proceedingJoinPoint.proceed();

        System.out.println("around后.....");
    }

}
